---
sidebar_class_name: node-only
---

import CodeBlock from "@theme/CodeBlock";

# Faiss

:::tip Compatibility
Only available on Node.js.
:::

[Faiss](https://github.com/facebookresearch/faiss) is a library for efficient similarity search and clustering of dense vectors.

Langchainjs supports using Faiss as a vectorstore that can be saved to file. It also provides the ability to read the saved file from [Python's implementation](https://python.langchain.com/docs/integrations/vectorstores/faiss#saving-and-loading).

## Setup

Install the [faiss-node](https://github.com/ewfian/faiss-node), which is a Node.js bindings for [Faiss](https://github.com/facebookresearch/faiss).

```bash npm2yarn
npm install -S faiss-node
```

To enable the ability to read the saved file from [Python's implementation](https://python.langchain.com/docs/integrations/vectorstores/faiss#saving-and-loading), the [pickleparser](https://github.com/ewfian/pickleparser) also needs to install.

```bash npm2yarn
npm install -S pickleparser
```

## Usage

import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";

<IntegrationInstallTooltip></IntegrationInstallTooltip>

```bash npm2yarn
npm install @langchain/openai @langchain/community
```

### Create a new index from texts

import ExampleTexts from "@examples/indexes/vector_stores/faiss.ts";

<CodeBlock language="typescript">{ExampleTexts}</CodeBlock>

### Create a new index from a loader

import ExampleLoader from "@examples/indexes/vector_stores/faiss_fromdocs.ts";

<CodeBlock language="typescript">{ExampleLoader}</CodeBlock>

### Deleting vectors

import ExampleDelete from "@examples/indexes/vector_stores/faiss_delete.ts";

<CodeBlock language="typescript">{ExampleDelete}</CodeBlock>

### Merging indexes and creating new index from another instance

import ExampleMerge from "@examples/indexes/vector_stores/faiss_mergefrom.ts";

<CodeBlock language="typescript">{ExampleMerge}</CodeBlock>

### Save an index to file and load it again

import ExampleSave from "@examples/indexes/vector_stores/faiss_saveload.ts";

<CodeBlock language="typescript">{ExampleSave}</CodeBlock>

### Load the saved file from [Python's implementation](https://python.langchain.com/docs/integrations/vectorstores/faiss#saving-and-loading)

import ExamplePython from "@examples/indexes/vector_stores/faiss_loadfrompython.ts";

<CodeBlock language="typescript">{ExamplePython}</CodeBlock>
